<?php

// +----------------------------------------------------------------------
// | Think.Admin
// +----------------------------------------------------------------------
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目：https://github.com/zoujingli/Think.Admin
// +----------------------------------------------------------------------

namespace app\admin\controller;

use controller\BasicAdmin;
use service\DataService;
use think\Db;

/**
 * 系统商品酒商管理
 * Class Sellers
 * @package app\admin\controller
 * @author Anyon <zoujingli@qq.com>
 * @date 2017/02/15 18:12
 */
class Sellers extends BasicAdmin
{

    /**
     * 指定当前数据表
     * @var string
     */
    public $table = 'ShopSellers';

    /**
     * 商品商户列表
     */
    public function index()
    {
        $this->title = '商品商户管理';
        $get = $this->request->get();
        $db = Db::name($this->table);
                
        foreach (['sname'] as $key) {
            (isset($get[$key]) && $get[$key] !== '') && $db->whereLike($key, "%{$get[$key]}%");
        }
        return parent::_list($db);
    }


    /**
     * 商品商户添加
     */
    public function add()
    {
        return $this->_form($this->table, 'form');
    }

    /**
     * 商品商户编辑
     */
    public function edit()
    {
        return $this->_form($this->table, 'form');
    }


    /**
     * 删除商品商户
     */
    public function del()
    {
        if (DataService::update($this->table)) {
            $this->success("商品商户删除成功！", '');
        }
        $this->error("商品商户删除失败，请稍候再试！");
    }

    /**
     * 商品商户禁止
     */
    public function forbid()
    {
        if (DataService::update($this->table)) {
            $this->success("商品商户禁止成功！", '');
        }
        $this->error("商品商户禁止失败，请稍候再试！");
    }

    /**
     * 商品商户禁用
     */
    public function resume()
    {
        if (DataService::update($this->table)) {
            $this->success("商品开启成功！", '');
        }
        $this->error("商品开启失败，请稍候再试！");
    }

}
